/**
 * 
 */
package org.huanglei.account.view.adapter;

import org.huanglei.account.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 
 * @author huanglei
 * @data Jul 6, 2012
 */
public class DashboardAdapter extends BaseAdapter {

/*	// 名称
	private final int[] ITEMS_NAME = { R.string.account_add,
			R.string.account_list, R.string.account_analyze,
			R.string.account_report, R.string.account_backup };*/
	
	// 名称
	private final int[] ITEMS_NAME = { R.string.account_add,
			R.string.account_list, 
			R.string.account_report, R.string.account_backup };

/*	// 索引
	private final int[] ITEMS_INDEX = { R.drawable.add, R.drawable.moneys,
			R.drawable.analyze, R.drawable.report_up, R.drawable.jigsaw };*/
	
	// 索引
	private final int[] ITEMS_INDEX = { R.drawable.add, R.drawable.moneys,
			 R.drawable.report_up, R.drawable.jigsaw };

	// activitys class name
	private final String[] ACTIVITY_CLASS_NAME;

	private final Context context;

	public DashboardAdapter(Context context) {
		this.context = context;
		ACTIVITY_CLASS_NAME = context.getResources().getStringArray(
				R.array.activitys);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getCount()
	 */
	@Override
	public int getCount() {
		return ITEMS_INDEX.length;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getItem(int)
	 */
	@Override
	public Object getItem(int position) {
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getItemId(int)
	 */
	@Override
	public long getItemId(int position) {
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.Adapter#getView(int, android.view.View,
	 * android.view.ViewGroup)
	 */
	@Override
	public View getView(int position, View view, ViewGroup parent) {
		view = LayoutInflater.from(context).inflate(
				R.layout.account_dashboard_item, null);
		ImageView imageView = (ImageView) view
				.findViewById(R.id.dashboard_item_image_view);
		imageView.setImageResource(ITEMS_INDEX[position]);
		TextView textView = (TextView) view
				.findViewById(R.id.dashboard_item_text_view);
		textView.setText(ITEMS_NAME[position]);
		if (position < ACTIVITY_CLASS_NAME.length) {
			view.setTag(ACTIVITY_CLASS_NAME[position]);
		}
		return view;
	}
}
